package com.itheima.web.controller;

import com.itheima.web.manager.AnalysisManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class AnalysisController {

    @Autowired
    private AnalysisManager analysisManager;

    // 统计展示
    @GetMapping("/dashboard/summary")
    public ResponseEntity findSummaryVo(){
        return analysisManager.findSummaryVo();
    }
    //新增、活跃用户、次日留存率
    @GetMapping("/dashboard/users")
    public ResponseEntity findView(@RequestParam Map<String,String> param){
        //接收参数
        Long startTime = Long.parseLong(param.get("sd"));
        Long endTime = Long.parseLong(param.get("ed"));
        Integer type = Integer.parseInt(param.get("type"));
        //调用manager
        return analysisManager.findView(startTime,endTime,type);
    }

}
